const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')
const AutoImport = require('unplugin-auto-import/webpack')
const Components = require('unplugin-vue-components/webpack')
const { ElementPlusResolver } = require('unplugin-vue-components/resolvers')
const { VueAmapResolver } = require('@vuemap/unplugin-resolver')

const path = require('path');

module.exports = {
    chainWebpack(config) {
        const oneOfsMap = config.module.rule('scss').oneOfs.store
        oneOfsMap.forEach((item) => {
            item
                .use('sass-resources-loader')
                .loader('sass-resources-loader')
                .options({
                    resources: './src/assets/base.scss'
                })
                .end()
        })
        config
            .plugin('html')
            .tap(args => {
                args[0].title= '翠微旅居云平台'
                return args
            })
    },
    configureWebpack: {
        plugins: [
            new NodePolyfillPlugin(),
            AutoImport({
                resolvers: [ElementPlusResolver({
                    exclude: /^ElAmap[A-Z]*/
                }), VueAmapResolver()],
            }),
            Components({
                resolvers: [ElementPlusResolver({
                    exclude: /^ElAmap[A-Z]*/
                }), VueAmapResolver()],
            }),
        ],
        resolve: {
            alias: {
                '@': path.resolve(__dirname, './src'),
                '@net': path.resolve(__dirname, './src/common/net'),
                '@ui': path.resolve(__dirname, './src/common/ui'),
                '@util': path.resolve(__dirname, './src/common/utils'),
                '@api': path.resolve(__dirname, './src/api'),
                '@com': path.resolve(__dirname, './src/components'),
                '@store': path.resolve(__dirname, './src/store'),
                '@router': path.resolve(__dirname, './src/router'),
                '@view': path.resolve(__dirname, './src/views'),
            }
        },
        // devServer: {
        //     proxy: "http://wxtestadmin.cwljky.com"
        // }
    },
    outputDir: '../TravelManageProject',
    // publicPath: './'
}